package com.ncr.travel.appmgr.client.ui;

import java.util.List;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * @author ng185038
 * 
 */
public class ConfirmationDialog extends DialogBox {

	private Button yesBtn;
	private Button noBtn;

	private FlowPanel mainPanel = new FlowPanel();

	public ConfirmationDialog(String confirmText, List<String> configurationChanges) {
		super();
		yesBtn = new Button("Yes");
		noBtn = new Button("No");
		FlexTable buttonsPnl = new FlexTable();
		buttonsPnl.setCellSpacing(10);
		buttonsPnl.setWidget(0, 0, yesBtn);
		buttonsPnl.setWidget(0, 1, noBtn);

		VerticalPanel buttonsMainPnl = new VerticalPanel();
		buttonsMainPnl.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
		buttonsMainPnl.setWidth("100%");
		buttonsMainPnl.add(new HTML("<HR>"));
		buttonsMainPnl.add(buttonsPnl);

		VerticalPanel dialogVPanel = new VerticalPanel();
		dialogVPanel.addStyleName("dialogVPanel");
		dialogVPanel.add(new Label(confirmText));
		dialogVPanel.add(new HTML("<BR>"));
		if (configurationChanges != null) {
			for (String configChange : configurationChanges) {
				dialogVPanel.add(new Label(configChange));
				dialogVPanel.add(new HTML("<BR>"));
			}
		}
		ScrollPanel sp = new ScrollPanel();
		sp.setSize("400px", "75px");
		sp.setWidget(dialogVPanel);

		mainPanel.add(sp);
		mainPanel.add(buttonsMainPnl);
		setWidget(mainPanel);
		setAutoHideEnabled(false);
		setAnimationEnabled(true);
		setGlassEnabled(true);
		setText("Confirmation");
		yesBtn.setFocus(true);
	}

	public void showView() {
		center();
	}

	public Button getYesBtn() {
		return yesBtn;
	}

	public void setYesBtn(Button yesBtn) {
		this.yesBtn = yesBtn;
	}

	public Button getNoBtn() {
		return noBtn;
	}

	public void setNoBtn(Button noBtn) {
		this.noBtn = noBtn;
	}
}